<template>
  <div class="box">{{ 1 + 1 }}</div>
  <div>
    <testComponent :list="item.list" v-for="(item, index) in objects" :key="index"></testComponent>
    <button @click="add">添加</button>
    <div>
      {{ list }}
    </div>
  </div>
</template>
<script>
import testObj from './objects/testObj.class.js'
import testComponent from './objects/testComponent.vue'
import { ref } from 'vue'
export default {
  components: {
    testComponent
  },
  data() {
    return {
      objects: []
    }
  },
  methods: {
    add() {
      this.objects.forEach((res) => {
        res.add()
      })
    }
  },
  watch: {
    list: {
      deep: true,
      handler() {
        console.log(`修改了list`, this.list)
      }
    }
  },
  mounted() {
    let to = new testObj()
    this.objects.push(new testObj())
    this.objects.push(new testObj())
    this.objects.push(new testObj())
    this.objects.push(new testObj())
  }
}
</script>
<style type="text/css">
.box {
  width: 100px;
  height: 100px;
  border: 1px solid #000;
}
</style>
